package com.phaethon.centerofuser.common;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

//lombok.Data自动生成get set方法

/**
 * 通用返回类
 *
 * @author phaethon
 * @param <T>
 */
@Data
public class BaseResponse<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = -4853010060536274170L;
    private int code;
    private String message;
    private T data;
    private String description;

    public BaseResponse(int code, String message, T data, String description) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.description = description;
    }

    public BaseResponse(int code,  T data) {
        this.code = code;
        this.message = null;
        this.data = data;
        this.description = null;
    }

    public BaseResponse(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
        this.data = null;
        this.description = errorCode.getDescription();
    }

    public BaseResponse(int code, String message,String description) {
        this.code = code;
        this.message = message;
        this.data = null;
        this.description = description;
    }


}
